package com.aletto.general_store.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class NumberUtil {

    private NumberUtil() {

    }

    public static String format(BigDecimal value, int mantissa){

        return new DecimalFormat("0.00##").format(value);
    }

    public static String format(double value, int mantissa){
        String pattern = "########." + mantissa(mantissa);
        return new DecimalFormat(pattern).format(value);
    }

    private static String mantissa(int mantissa){
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < mantissa; i++) {
            sb.append("#");
        }

        return sb.toString();
    }


}
